#!/bin/bash
#This shell script is used in the program of serial_face.cpp(int the board RV1126)
#v1.0	将拍照和图片存数据库的代码整合(正点原子的例程)
program_dir=/home/face_recognize

echo "Script received args: $@"

echo "taking picture..."
"$program_dir/jpegtest"

if [ $? -ne 0 ]; then
	echo "Error: jpegtest executed err!"
	exit 1
fi

echo "import_face_library...   $1"
#将图片以及名字存入数据库
#$1: the name of person in the picture(from serial_face.cpp)
for img in "$program_dir/face_database/image/"*; do
	$program_dir/import_face_library $1 $img
	if [ $? -ne 0 ]; then
		echo "Error: import_face_library executed err!"
		exit 1
	fi
done


echo "Shell Execute Over!"
exit 0
